<template>
	<view class="add">
		<view class="a1">
			<text>姓名：</text>
			<input type="text" placeholder="请输入姓名" v-model="name"/>
		</view>
		<u-line></u-line>
		<view class="a1">
			<text>性别：</text>
			<input type="text" placeholder="请输入性别" v-model="sex"/>
		</view>
		<u-line></u-line>
		<view class="a1">
			<text>出生年月：</text>
			<input type="text" placeholder="请输入出生年月" v-model="birthday"/>
		</view>
		<u-line></u-line>
		<view class="a1">
			<text>身份证：</text>
			<input type="text" placeholder="请输入身份证" v-model="id"/>
		</view>
		<u-line></u-line>
		<view class="a1">
			<text>地址：</text>
			<input type="text" placeholder="请输入地址" v-model="address"/>
		</view>
		<u-line></u-line>
		<view class="a1">
			<text>电话：</text>
			<input type="text" placeholder="请输入电话" v-model="tel"/>
		</view>
		<u-line></u-line>
		<u-button type="primary" text="保存" style="margin-top: 10px;" @click="addque"></u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:'',
				sex:'',
				birthday:'',
				id:'',
				address:'',
				tel:''
			}
		},
		onLoad() {
			uni.setNavigationBarTitle({
				title:'新增确诊人'
			})
		},
		methods: {
			addque(){
				if(this.name===''||this.sex===''||this.birthday===''||this.id===''||this.address===''||this.tel===''){
					uni.showToast({
						title:'参数错误',
						icon:'error'
					})
				}else{
					
					const data={
						name:this.name,
						sex:this.sex,
						birthday:this.birthday,
						cardId:this.id,
						address:this.address,
						tel:this.tel
					}
					this.api.get('/prod-api/api/hospital/patient','POST',data).then(res=>{
						console.log(res.data)
						if(res.data.code===200){
							setTimeout(function(){
								uni.showToast({
									title:'保存成功'
								})
							},700)
						}else{
							setTimeout(function(){
								uni.showToast({
									title:'保存失败',
									icon:'error'
								})
							},700)
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss">
.a1{
	display: flex;
	margin-top: 20px;
	margin-bottom: 20px;
}
</style>
